<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        // let resName = "老王"
        // let resAge = 18;
        // let resSex = '男';

        // let obj = {
        //     name:resName,
        //     age:resAge,
        //     sex:resSex
        // }

        // console.log(obj);

        // es6简写，简写条件：属性名必须和变量名一致。
        // let name = "老王"
        // let age = 18;
        // let sex = '男';

        // let obj = {
        //     name,
        //     age,
        //     sex,
        // }

        // console.log(obj);

        
        // 属性名：改成变量,允许任何形式的数据，作为属性名存在。
        let name = 'mingzi';
        let age = "年龄";

        let arr = [1,2,3];
        let fn = function(){
            console.log(123);
        }

        let obj = {
            [name]:"老王",
            [age]:18,
            [arr]:"哈哈哈",
            [fn]:"666"
        }

        console.log(obj);

        // console.log(obj.年龄);

        // console.log(obj[arr]);

        // console.log(obj[fn]);


    </script>
</body>
</html>